package com.ffyc.cms.controller;
import com.ffyc.cms.common.CommonResult;
import com.ffyc.cms.model.Website;
import com.ffyc.cms.service.WebSiteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * 这里是主页查询显示网站信息控制层
 */
@RestController
@RequestMapping(path = "website")
public class WebSiteController {
    @Autowired
    WebSiteService webSiteService;
    @RequestMapping(path = "getWebSite")
    public CommonResult getWebSite(){
        CommonResult commonResult=null;
        try{
            Website webSite = webSiteService.getWebSite();
            if (webSite==null){
                commonResult=new CommonResult(201,"网站信息查询为空",null);
            }
            else{
                commonResult=new CommonResult(200,"网站信息查询成功!",webSite);
            }
        }catch (Exception e){
            e.printStackTrace();
            commonResult=new CommonResult(500,"网站信息查询失败",null);
        }
        return commonResult;
    }
}
